<template>
	<view>
		<view class="bagW">
			<view v-for="(item,index) in data" :key='item.key'>
				<input-comp :title="item.title" :type="item.type"
						   :item="item"
						   :defaultValue="item.value"
						   :params="item.params || null"
						   @onChange="onChange($event,item.key)"
						   :reqiure="item.reqiure" :fail="item.fail"></input-comp>
			</view>
		</view>
	</view>
</template>

<script>
	import forEach from "lodash/forEach"
    export default {
       data(){
       	return {
			data:[
				{key:'comment',title:'报销事由',type:"textarea",value:'',reqiure:true,fail:false,},
				{key:'bizDate',title:'业务时间',type:"dateTimePicker",value:'',reqiure:true,fail:false,},
				{key:'employee',title:'报销人',type:"pickerSelect",
					value:'',reqiure:true,fail:false,params:{api:'xxxapi'}},
			]
		}
	   },
		methods:{
			onChange(values,fileName){

				let { value, fail, selectedObj } = values;
				forEach(this.data,item=>{
					if(item.key === fileName){
						item.value = value;
						item.fail = fail;
					}
				});
				// console.log("this.data>>>>:",this.data);
			},
		}
    }
</script>

<style scoped>

</style>
